package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.Member;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface MemberDao_scg {
    @Select("select * from t_member")
    public List<Member> findAll();

    @Select("select * from t_member where fileNumber = #{fileNumber} or phoneNumber = #{phoneNumber} or name = #{name}")
    public Page<Member> selectByCondition(String queryString);

    @Insert("insert into t_member(fileNumber,name,sex,idCard,phoneNumber,regTime,password,email,birthday,remark) values (#{fileNumber},#{name},#{sex},#{idCard},#{phoneNumber},#{regTime},#{password},#{email},#{birthday},#{remark})")
    @Options(useGeneratedKeys = true)
    public void add(Member member);

    @Delete("delete from t_member where id = #{id}")
    public void deleteById(Integer id);

    @Select(" select * from t_member where id = #{id}")
    public Member findById(Integer id);

    @Select("select * from t_member where phoneNumber = #{telephone}")
    public Member findByTelephone(String telephone);

    @Update("update t_member set fileNumber = #{fileNumber},name = #{name},sex = #{sex},idCard = #{idCard},phoneNumber = #{phoneNumber},regTime = #{regTime},password = #{password},email = #{email},birthday = #{birthday},remark = #{remark} where id = #{id}")
    public void edit(Member member);

    @Select("select count(id) from t_member where regTime <= #{value}")
    public Integer findMemberCountBeforeDate(String date);

    @Select("select count(id) from t_member where regTime = #{value}")
    public Integer findMemberCountByDate(String date);

    @Select("select count(id) from t_member where regTime >= #{value}")
    public Integer findMemberCountAfterDate(String date);

    @Select("select count(id) from t_member")
    public Integer findMemberTotalCount();

    @Select("select * from t_member where idCard=#{idCard}")
    List<Member> findByIdCard(String idCard);

    @Update("update t_member set name =#{name},phoneNumber=#{phoneNumber},sex=#{sex} where id =#{member_id}")
    void update(@Param("name") String name, @Param("phoneNumber") String phoneNumber, @Param("sex") String sex, @Param("member_id") int member_id);

}
